package com.zlk.controller;

import com.zlk.pojo.User;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/zlk")
@Api(tags = "Hello相关接口描述")
public class Hello {

    @GetMapping("/hello")
    public String hello(){
        return "hello";
    }
    @PostMapping("/getUser")
    public User getUser(){
        return new User();
    }
    @GetMapping("/hello2")
    @ApiOperation(value = "hello接口",notes = "hello接口详细描述")
    public String hello2(@ApiParam("用户名") String username){
        return "hello"+username;
    }

    @GetMapping("/hello3")
    @ApiOperation(value = "hello3接口",notes = "hello3接口详细描述")
    @ApiImplicitParams({
            @ApiImplicitParam(name="username",value = "用户名"),
            @ApiImplicitParam(name="password",value="密码")
    })
    public String hello3(String username,String password){
        return "hello"+username+"\t"+password;
    }

    @GetMapping("/hello4/{username}/{password}")
    @ApiOperation(value = "hello4接口",notes = "hello4接口详细描述")
    @ApiImplicitParams({
            @ApiImplicitParam(name="username",value = "用户名",paramType ="path"),
            @ApiImplicitParam(name="password",value="密码",paramType = "path")
    })
    public String hello4(@PathVariable("username") String username, @PathVariable("password") String password){
        return "hello"+username+"\t"+password;
    }

    @GetMapping("/hello5")
    @ApiOperation(value = "hello5接口",notes = "hello5接口详细描述")
    @ApiImplicitParams({
            @ApiImplicitParam(name="username",value = "用户名",paramType = "body"),
            @ApiImplicitParam(name="password",value="密码",paramType = "body")
    })
    public String hello5(@RequestBody String username, @RequestBody String password){
        return "hello"+username+"\t"+password;
    }
    @GetMapping("/hello6")
    @ApiOperation(value = "hello接口",notes = "hello接口详细描述")
    public void hello6(@RequestBody User user){
        System.out.println("通过json格式对象传参");
    }

}
